package com.bootdo.clouddobase.controller;


import cn.wanghaomiao.seimi.core.Seimi;

import cn.wanghaomiao.seimi.spring.common.CrawlerCache;
import cn.wanghaomiao.seimi.struct.CrawlerModel;
import cn.wanghaomiao.seimi.struct.Request;
import com.bootdo.clouddobase.crawlers.MyThread;
import com.bootdo.clouddobase.crawlers.data;
import org.springframework.web.bind.annotation.*;

@RequestMapping("/SeimiCrawler")
@RestController
public class SeimiCrawler {
    @GetMapping("/basic")
    String basic() {
        CrawlerModel model = CrawlerCache.getCrawlerModel("data");
        if (model == null) {
            model.sendRequest(new Request("https://pindao.suning.com/city/bingxi.html",data::getTitle));
            return "not find " + "data";
        }

        return model.queueInfo();


    }
    @RequestMapping("/send_req")
    public String sendRequest(Request request){
        CrawlerCache.consumeRequest(request);
        return "consume suc";
    }

}
